package com.service.impl;

import com.entity.Addinto;
import com.entity.Category;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.CategoryMapper;
import com.service.CategoryService;
import com.vo.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author :hcy
 * @date:
 * @description:
 */
@Service
public class CategoryServiceIml implements CategoryService {
    @Resource
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> listAll() {
        return categoryMapper.listAll();
    }

    @Override
    public PageInfo<Category> list(Page<Category> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        List<Category> list = categoryMapper.list(page.getData());
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public Category queryById(Integer categoryId) {
        return categoryMapper.queryById(categoryId);
    }

    @Override
    public int insert(Category category) {
        return categoryMapper.insert(category);
    }

    @Override
    public int update(Category category) {
        return categoryMapper.update(category);
    }

    @Override
    public int deleteById(Integer categoryId) {
        return categoryMapper.deleteById(categoryId);
    }

    @Override
    public List<Category> lists() {
        return categoryMapper.lists();
    }
}
